<table width="100%">
    <thead>
        <th><?php echo __('Amount') ?></th>
        <th><?php echo __('Date') ?></th>
        <th><?php echo __('Collateral') ?></th>
        <th align="center" colspan="3"><?php echo __('Recommender') ?></th>
        <th class="action"><?php echo __('Action'); ?></th>
    </thead>
    <tbody>
        <tr>
            <th colspan="3"></th>
            <th><?php echo __('Name') ?></th>
            <th><?php echo __('Citizenship No') ?></th>
            <th><?php echo __('Passport') ?></th>
            <th>&nbsp;</th>
        </tr>
        <?php if($this->loans): ?>
            <?php foreach($this->loans as $key => $loan): ?>
                <tr class="<?php echo ($key % 2 == 0)?'even':'odd'; ?>">
                    <td><?php echo $loan['amount']; ?></td>
                    <td><?php echo $loan['date']; ?></td>
                    <td><?php echo ($loan['security']) ?$loan['security']:"--";  ?></td>
                    <td><?php echo $loan['recommender_name'] ?></td>
                    <td><?php echo $loan['recommender_citizenship_no'] ?></td>
                    <td><?php echo ($loan['recommender_passport'])? $loan['recommender_passport']:"--"; ?></td>
                    <td><a class="edit" id="edit" edit:url="<?php echo $this->baseUrl('service/loan/edit/lid/'.Custom_General::encode($loan['id']))?>">&nbsp;</a>
                        <a class="delete"
                           del:url="<?php echo $this->siteURL.'/service/loan/delete/lid/'.Custom_General::encode($loan['id']); ?><?php echo ($this->page)?"/page/".$this->page:''; ?>">&nbsp;
                        </a>
                    </td>
                </tr>
            <?php endforeach; ?>
        <?php else: ?>
                <tr><td colspan="7" align="center"><?php echo __('Loan not found'); ?></td></tr>
        <?php endif; ?>
    </tbody>
</table>
<?php echo $this->pagination();?>
<script type="text/javascript">


$(document).ready(function(){
//edit loan
    $('#edit').click(function(){
            var url = $(this).attr('edit:url');
            $('<div id="ss"></div>').dialog({
                width:550,
                modal:true,
                resizable:false,
                position:'center',
                title:'<?php echo __('Loan Edit') ?>',
                close:function(){$('#ss').remove();},
                open:function(){
                    $(this).html('<?php echo __('Loading...'); ?>');
                    $(this).load(url,'',function(){});
                }
            });
        });
//delete loan
	$('.delete').click(function(){
		setDeleteDialog($(this).attr('del:url'), "Are you sure, you want to delete this Loan ?");
	});
});
</script>